#! /usr/bin/env	python
#encoding=utf-8
#生成订单评论表数据

import MySQLdb,string,os,sys,random

try:
	conn = MySQLdb.connect(host ='10.102.107.22',user ='dba',passwd = '1q2w3e4r',db = 'imooc',charset="utf8")
except MySQLdb.Error, e:
	print "Error %d: %s \n" % (e.args[0], e.args[1])

for i in range(0,10000):
	#随机获取用户ID
	customerid=random.randint(1,10010)
	sencondes=random.randint(86400,7776000)
	cursor= conn.cursor(MySQLdb.cursors.DictCursor)

	#生成登录日志
	sqlstr="""
     INSERT INTO imooc.`customer_login_log`(customer_id,login_time,login_ip,login_type) 
     values(%d,DATE_ADD(NOW(),INTERVAL %d SECOND),0,1)
	"""%(customerid,sencondes)

	cursor.execute(sqlstr)
	cursor.execute('commit;')